package io.lhj.chapter03;

public class ThreadSleep {

    public static void main(String[] args)
    {
        int a = 2000;
        new Thread(() ->
        {
            long startTime = System.currentTimeMillis();
            sleep(2_000L);
            long endTime = System.currentTimeMillis();
            System.out.println(String.format("Total spend %d ms", (endTime - startTime)));
        }).start();
        long startTime = System.currentTimeMillis();
        sleep(3_000L);
        long endTime = System.currentTimeMillis();
        System.out.println(String.format("Main thread total spend %d ms", (endTime - startTime)));
    }
    private static void sleep(long ms)
    {
        try
        {
            Thread.sleep(ms);
            Thread.sleep(1000, 1000);
        } catch (InterruptedException e)
        {
        }
    }
}
